import java.util.Arrays;

public class Solution1732 {
    public int largestAltitude(int[] gain) {
        int[] f=new int[gain.length+1];
        for (int i=0;i<gain.length;i++){
            f[i+1]=f[i]+gain[i];
        }
        return Arrays.stream(f).max().getAsInt();
    }

    public static void main(String[] args) {
        System.out.println(new Solution1732().largestAltitude(new int[]{-5,1,5,0,-7}));
    }
}
